package com.zp.clone;
/**
 * 浅复制：
 * 打印结果：
 * 20
 * zhangpeng
 * ===================
 * zhangpeng
 * lisi
 */
public class CloneTest1 {
	public static void main(String[] args) throws Exception {
		Student student1 = new Student();
		student1.setAge(20);
		student1.setName("zhangpeng");
		
		Student student2 = (Student)student1.clone();
		
		System.out.println(student2.getAge());
		System.out.println(student2.getName());
		
		System.out.println("===================");
		
		student2.setAge(30);
		student2.setName("lisi");
		
		System.out.println(student1.getName());
		System.out.println(student2.getName());
	}
}

class Student implements Cloneable{
	
	private int age;
	private String name;
	
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@Override
	public Object clone() throws CloneNotSupportedException {
		//浅复制；
		Object object = super.clone();
		return object;
	}
}